<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <base href="<%=basePath%>">
    <title>超市后台</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/bootstrap.min.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/main.css">
    <script src="${pageContext.request.contextPath}/js/jquery.min.js"></script>
	<script src="${pageContext.request.contextPath}/js/bootstrap.min.js"></script>
	<script src="${pageContext.request.contextPath}/js/main.js"></script>
	<script src="http://cdn.bootcss.com/angular.js/1.4.5/angular.min.js"></script>
	<script src="${pageContext.request.contextPath}/js/MD5.js"></script>
	
</head>
<body>
<%@ include file="header.jsp" %>
<%@ include file="left.jsp" %>
<div id="index" style="position: absolute;left: 180px;top: 80px;bottom: 0;right: 0;">
<section id="main">
    <div class="scrollbar1-1" id="style1-1">
        <div class="main_div">
            <div class="main_title">
                <span>修改登录密码</span>
            </div>
            <form class="form-horizontal" style="margin-top: 60px">
                <div class="form-group">
                    <label  class="col-xs-1 control-label" style="text-align: right">旧密码</label>
                    <div class="col-xs-3">
                        <input type="text" id="oldPassword" class="form-control"  placeholder="请输入旧密码">
                    </div>
                </div>
                <div class="form-group">
                    <label  class="col-xs-1 control-label" style="text-align: right">新密码</label>
                    <div class="col-xs-3">
                        <input type="password"" id="newPassword1" class="form-control"  placeholder="请输入新密码">
                    </div>
                </div>
                <div class="form-group">
                    <label  class="col-xs-1 control-label" style="text-align: right">确认新密码</label>
                    <div class="col-xs-3">
                        <input type="password" id="newPassword2" class="form-control"  placeholder="请再次输入新密码">
                    </div>
                </div>
                <div class="form-group">
                    <div  class="col-xs-4 col-xs-offset-1">
                        <button type="button" class="col-xs-6 btn btn-primary" onclick="submitPassword()">确认修改</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
</section>
</div>
<script>
 
   function submitPassword(){
       var card=/^[a-z0-9A-Z_-]{6,20}$/;
     var newPassword1=$("#newPassword1").val();
     var oldPassword=$("#oldPassword").val();
      var newPassword2=$("#newPassword2").val();
     if(!card.test(newPassword1)){
       alert("请输入6到20位由数字、字母、下划线、减号组成的密码")
     }else {
        if(newPassword1!=newPassword2){
           alert("两次密码不一致")
        }else{
        console.log($.md5(newPassword2))
           $.post(urls+"loginAction/modificationPassWord",
           {
              superId:localStorage.getItem("id"),
              oldPassWord:$.md5(oldPassword),
              newPassWord:$.md5(newPassword2)
           },
           function(data){
              if(data==true){
               alert("修改密码成功");
               $("#newPassword1").val("");
               $("#oldPassword").val("");
               $("#newPassword2").val("")
              }else{
               alert("修改密码失败")
              }
           })
        }
     }
   }
      
</script>
</body>
</html>